﻿CREATE TABLE [dbo].[UndoAttributes] (
    [UndoAttributesID] INT            IDENTITY (1, 1) NOT NULL,
    [EntityID]         INT            NOT NULL,
    [AttributeID]      INT            NOT NULL,
    [OldData]          NVARCHAR (MAX) NULL,
    [NewData]          NVARCHAR (MAX) NULL,
    [UndoAction]       NVARCHAR (10)  NOT NULL,
    [ChangedBy]        INT            NOT NULL,
    [WhenChanged]      DATETIME       NOT NULL,
    CONSTRAINT [PK_UndoAttributes] PRIMARY KEY CLUSTERED ([UndoAttributesID] ASC),
    CONSTRAINT [FK_UndoAttributes_DefinedUndoActions] FOREIGN KEY ([UndoAction]) REFERENCES [dbo].[DefinedUndoActions] ([UndoAction]),
    CONSTRAINT [FK_UndoAttributes_Entity1] FOREIGN KEY ([ChangedBy]) REFERENCES [dbo].[Entities] ([EntityID])
);

